package com.luych.toolbox.common.feign.view.base.service;

import com.luych.toolbox.common.feign.FeignView;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import java.util.List;
import java.util.stream.Collectors;

@ApiModel("角色信息")
public class RoleView extends FeignView {

    @ApiModelProperty("角色名称")
    private String roleName;
    @ApiModelProperty("角色包含权限列表")
    private List<PermissionView> permissions;
    @ApiModelProperty("角色包含用户列表")
    private List<UserView> users;

    public String getRoleName() {
        return roleName;
    }

    public void setRoleName(String roleName) {
        this.roleName = roleName;
    }

    public List<PermissionView> getPermissions() {
        return permissions;
    }

    public void setPermissions(List<PermissionView> permissions) {
        this.permissions = permissions;
    }

    public List<UserView> getUsers() {
        return users;
    }

    public void setUsers(List<UserView> users) {
        this.users = users;
    }

    public String getPermissionNames() {
        if (this.permissions == null) return null;
        return this.permissions.stream().map(PermissionView::getPermissionName).collect(Collectors.joining(","));
    }

    public String getUserNames() {
        if (this.users == null) return null;
        return this.users.stream().map(UserView::getUserName).collect(Collectors.joining(","));
    }

    public List<String> getPermissionIds() {
        if (this.permissions == null) return null;
        return this.permissions.stream().map(PermissionView::getId).collect(Collectors.toList());
    }
}
